package sd.qd.xiaoming.coffeedesk.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import sd.qd.xiaoming.coffeedesk.dao.CdDictDAO;

@Controller
@RequestMapping("/")
public class MainController {

	@Resource
	private CdDictDAO        dao;

	@RequestMapping(method = RequestMethod.GET)
	public String toIndex(final Model model) {
		model.addAttribute("app_name", this.dao.findByCode("app_name").getName());
		model.addAttribute("app_author", this.dao.findByCode("app_author")
				.getName());
		return "index";
	}

	@ResponseBody
	@RequestMapping("/testjson")
	public Object getJsonTest() {
		Map<String, Object> result = new HashMap<String, Object>();

		result.put("key", "value");
		result.put("kkk", "vvv");

		return result;
	}

}
